import pytest
from common.request_util_test import RequestUtil
from common.test_yaml_util_test import YamlUtil
from datetime import datetime,timedelta
from config import datas


class Testmonitoring:

    @pytest.mark.parametrize('monitoringinfo', YamlUtil().read_testcase_yaml('v24.06/monitoring/1_get_cluster_metric.yaml'))
    def test_get_cluster_metric(self, monitoringinfo, get_env_info):
        # 查询集群级别的指标数据
        baseUrl = get_env_info
        if '{time}' in monitoringinfo['request']['url']:
            url = baseUrl + monitoringinfo['request']['url'].replace('{time}',str(datetime.now()).split('.')[0])
        else:
            url = baseUrl + monitoringinfo['request']['url']
        method = monitoringinfo['request']['method']
        req = RequestUtil().send_request(method, url)
        assert req.status_code == monitoringinfo['validate'][0]['equals']['status_code']

    @pytest.mark.parametrize('monitoringinfo', YamlUtil().read_testcase_yaml('v24.06/monitoring/1_get_cluster_metrics_range_vector.yaml'))
    def test_get_cluster_metrics_range_vector(self, monitoringinfo, get_env_info):
        # 查询集群级别的指标数据-范围向量
        baseUrl = get_env_info
        starttime = datetime.now() - timedelta(minutes=10)
        endtime = datetime.now()
        url = baseUrl + monitoringinfo['request']['url'].replace('{starttime}',str(starttime).split('.')[0]).replace('{endtime}',str(endtime).split('.')[0]).replace('{steptime}','5m')
        method = monitoringinfo['request']['method']
        req = RequestUtil().send_request(method, url)
        assert req.status_code == monitoringinfo['validate'][0]['equals']['status_code']

    @pytest.mark.parametrize('monitoringinfo', YamlUtil().read_testcase_yaml('v24.06/monitoring/2_get_node_metric.yaml'))
    def test_get_node_metric(self, monitoringinfo, get_env_info):
        # 查询节点级别的指标数据
        baseUrl = get_env_info
        url = baseUrl + monitoringinfo['request']['url'].replace('{nodename}',datas.hostname)
        method = monitoringinfo['request']['method']
        req = RequestUtil().send_request(method, url)
        assert req.status_code == monitoringinfo['validate'][0]['equals']['status_code']

    @pytest.mark.parametrize('monitoringinfo', YamlUtil().read_testcase_yaml('v24.06/monitoring/2_get_node_metric_range_vector.yaml'))
    def test_get_node_metrics_range_vector(self, monitoringinfo, get_env_info):
        # 查询节点级别的指标数据-范围向量
        baseUrl = get_env_info
        starttime = datetime.now() - timedelta(minutes=10)
        endtime = datetime.now()
        url = baseUrl + monitoringinfo['request']['url'].replace('{nodename}',datas.hostname).replace('{starttime}',str(starttime).split('.')[0]).replace('{endtime}',str(endtime).split('.')[0]).replace('{steptime}','5m')
        method = monitoringinfo['request']['method']
        req = RequestUtil().send_request(method, url)
        assert req.status_code == monitoringinfo['validate'][0]['equals']['status_code']

    @pytest.mark.parametrize('monitoringinfo', YamlUtil().read_testcase_yaml('v24.06/monitoring/3_get_workload_metric_deployment.yaml'))
    def test_get_workload_metric_deployment(self, monitoringinfo, get_env_info):
        # 查询工作负载的指标数据-deployment
        baseUrl = get_env_info
        if '{podname}' in monitoringinfo['request']['url']:
            url = baseUrl + monitoringinfo['request']['url'].replace('{namespace}', 'monitoring').replace('{deployment}', 'prometheus-operator').replace('{podname}','prometheus-k8s-0')
        elif '{time}' in monitoringinfo['request']['url']:
            url = baseUrl + monitoringinfo['request']['url'].replace('{namespace}', 'monitoring').replace('{deployment}', 'prometheus-operator').replace('{time}',str(datetime.now()).split('.')[0])
        else:
            url = baseUrl + monitoringinfo['request']['url'].replace('{namespace}','monitoring').replace('{deployment}','prometheus-operator')
        method = monitoringinfo['request']['method']
        req = RequestUtil().send_request(method, url)
        assert req.status_code == monitoringinfo['validate'][0]['equals']['status_code']

    @pytest.mark.parametrize('monitoringinfo', YamlUtil().read_testcase_yaml('v24.06/monitoring/3_get_workload_metric_range_vector_deployment.yaml'))
    def test_get_workload_metric_range_vector_deployment(self, monitoringinfo, get_env_info):
        # 查询工作负载的指标数据-deployment-范围向量
        baseUrl = get_env_info
        starttime = datetime.now() - timedelta(minutes=10)
        endtime = datetime.now()
        url = baseUrl + monitoringinfo['request']['url'].replace('{namespace}', 'monitoring').replace('{deployment}', 'prometheus-operator').replace('{starttime}',str(starttime).split('.')[0]).replace('{endtime}', str(endtime).split('.')[0]).replace('{steptime}', '5m')
        method = monitoringinfo['request']['method']
        req = RequestUtil().send_request(method, url)
        assert req.status_code == monitoringinfo['validate'][0]['equals']['status_code']

    @pytest.mark.parametrize('monitoringinfo', YamlUtil().read_testcase_yaml('v24.06/monitoring/4_get_workload_metric_statefulset.yaml'))
    def test_get_workload_metric_statefulset(self, monitoringinfo, get_env_info):
        # 查询工作负载的指标数据-statefulset
        baseUrl = get_env_info
        if '{podname}' in monitoringinfo['request']['url']:
            url = baseUrl + monitoringinfo['request']['url'].replace('{namespace}', 'monitoring').replace('{statefulset}', 'prometheus-operator').replace('{podname}','prometheus-k8s-0')
        elif '{time}' in monitoringinfo['request']['url']:
            url = baseUrl + monitoringinfo['request']['url'].replace('{namespace}', 'monitoring').replace('{statefulset}', 'prometheus-operator').replace('{time}',str(datetime.now()).split('.')[0])
        else:
            url = baseUrl + monitoringinfo['request']['url'].replace('{namespace}','monitoring').replace('{statefulset}','prometheus-operator')
        method = monitoringinfo['request']['method']
        req = RequestUtil().send_request(method, url)
        assert req.status_code == monitoringinfo['validate'][0]['equals']['status_code']

    @pytest.mark.parametrize('monitoringinfo', YamlUtil().read_testcase_yaml('v24.06/monitoring/4_get_workload_metric_range_vector_statefulset.yaml'))
    def test_get_workload_metric_range_vector_statefulset(self, monitoringinfo, get_env_info):
        # 查询工作负载的指标数据-statefulset-范围向量
        baseUrl = get_env_info
        starttime = datetime.now() - timedelta(minutes=10)
        endtime = datetime.now()
        url = baseUrl + monitoringinfo['request']['url'].replace('{namespace}', 'monitoring').replace('{statefulset}','prometheus-operator').replace('{starttime}', str(starttime).split('.')[0]).replace('{endtime}', str(endtime).split('.')[0]).replace('{steptime}', '5m')
        method = monitoringinfo['request']['method']
        req = RequestUtil().send_request(method, url)
        assert req.status_code == monitoringinfo['validate'][0]['equals']['status_code']

    @pytest.mark.parametrize('monitoringinfo', YamlUtil().read_testcase_yaml('v24.06/monitoring/5_get_workload_metric_daemonset.yaml'))
    def test_get_workload_metric_daemonset(self, monitoringinfo, get_env_info):
        # 查询工作负载的指标数据-daemonset
        baseUrl = get_env_info
        if '{podname}' in monitoringinfo['request']['url']:
            url = baseUrl + monitoringinfo['request']['url'].replace('{namespace}', 'monitoring').replace(
                '{daemonset}', 'prometheus-operator').replace('{podname}','prometheus-k8s-0')
        elif '{time}' in monitoringinfo['request']['url']:
            url = baseUrl + monitoringinfo['request']['url'].replace('{namespace}', 'monitoring').replace(
                '{daemonset}', 'prometheus-operator').replace('{time}',str(datetime.now()).split('.')[0])
        else:
            url = baseUrl + monitoringinfo['request']['url'].replace('{namespace}','monitoring').replace('{daemonset}','prometheus-operator')
        method = monitoringinfo['request']['method']
        req = RequestUtil().send_request(method, url)
        assert req.status_code == monitoringinfo['validate'][0]['equals']['status_code']

    @pytest.mark.parametrize('monitoringinfo', YamlUtil().read_testcase_yaml('v24.06/monitoring/5_get_workload_metric_range_vector_daemonset.yaml'))
    def test_get_workload_metric_range_vector_daemonset(self, monitoringinfo, get_env_info):
        # 查询工作负载的指标数据-daemonset-范围向量
        baseUrl = get_env_info
        starttime = datetime.now() - timedelta(minutes=10)
        endtime = datetime.now()
        url = baseUrl + monitoringinfo['request']['url'].replace('{namespace}', 'monitoring').replace('{daemonset}','prometheus-operator').replace('{starttime}', str(starttime).split('.')[0]).replace('{endtime}', str(endtime).split('.')[0]).replace('{steptime}', '5m')
        method = monitoringinfo['request']['method']
        req = RequestUtil().send_request(method, url)
        assert req.status_code == monitoringinfo['validate'][0]['equals']['status_code']

    @pytest.mark.parametrize('monitoringinfo', YamlUtil().read_testcase_yaml('v24.06/monitoring/6_get_pod_metric.yaml'))
    def test_get_pod_metric(self, monitoringinfo, get_env_info):
        # 查询pod级别的指标数据
        baseUrl = get_env_info
        if '{time}' in monitoringinfo['request']['url']:
            url = baseUrl + monitoringinfo['request']['url'].replace('{namespace}', 'monitoring').replace('{podname}','prometheus-operator').replace('{time}',str(datetime.now()).split('.')[0])
        else:
            url = baseUrl + monitoringinfo['request']['url'].replace('{namespace}', 'monitoring').replace('{podname}','prometheus-operator')
        method = monitoringinfo['request']['method']
        req = RequestUtil().send_request(method, url)
        assert req.status_code == monitoringinfo['validate'][0]['equals']['status_code']

    @pytest.mark.parametrize('monitoringinfo', YamlUtil().read_testcase_yaml('v24.06/monitoring/6_get_pod_metric_range_vector.yaml'))
    def test_get_pod_metric_range_vector(self, monitoringinfo, get_env_info):
        # 查询pod级别的指标数据-范围向量
        baseUrl = get_env_info
        starttime = datetime.now() - timedelta(minutes=10)
        endtime = datetime.now()
        url = baseUrl + monitoringinfo['request']['url'].replace('{namespace}', 'monitoring').replace('{podname}','prometheus-operator').replace('{starttime}', str(starttime).split('.')[0]).replace('{endtime}', str(endtime).split('.')[0]).replace('{steptime}', '5m')
        method = monitoringinfo['request']['method']
        req = RequestUtil().send_request(method, url)
        assert req.status_code == monitoringinfo['validate'][0]['equals']['status_code']

    @pytest.mark.parametrize('monitoringinfo', YamlUtil().read_testcase_yaml('v24.06/monitoring/7_get_container_metric.yaml'))
    def test_get_container_metric(self, monitoringinfo, get_env_info):
        # 查询container级别的指标数据
        baseUrl = get_env_info
        if '{time}' in monitoringinfo['request']['url']:
            url = baseUrl + monitoringinfo['request']['url'].replace('{namespace}', 'monitoring').replace('{podname}','prometheus-operator').replace('{containername}','prometheus').replace('{time}',str(datetime.now()).split('.')[0])
        else:
            url = baseUrl + monitoringinfo['request']['url'].replace('{namespace}', 'monitoring').replace('{podname}','prometheus-operator')
        method = monitoringinfo['request']['method']
        req = RequestUtil().send_request(method, url)
        assert req.status_code == monitoringinfo['validate'][0]['equals']['status_code']

    @pytest.mark.parametrize('monitoringinfo', YamlUtil().read_testcase_yaml('v24.06/monitoring/7_get_container_metric_range_vector.yaml'))
    def test_get_container_metric_range_vector(self, monitoringinfo, get_env_info):
        # 查询container级别的指标数据-范围向量
        baseUrl = get_env_info
        starttime = datetime.now() - timedelta(minutes=10)
        endtime = datetime.now()
        url = baseUrl + monitoringinfo['request']['url'].replace('{namespace}', 'monitoring').replace('{podname}','prometheus-operator').replace('{containername}','prometheus').replace('{starttime}', str(starttime).split('.')[0]).replace('{endtime}', str(endtime).split('.')[0]).replace('{steptime}', '5m')
        method = monitoringinfo['request']['method']
        req = RequestUtil().send_request(method, url)
        assert req.status_code == monitoringinfo['validate'][0]['equals']['status_code']

    @pytest.mark.parametrize('monitoringinfo', YamlUtil().read_testcase_yaml('v24.06/monitoring/8_get_control_plane_metric_kubeapiserver.yaml'))
    def test_get_control_plane_metric_kubeapiserver(self, monitoringinfo, get_env_info):
        # 查询控制平面组件的指标数据-kube-apiserver
        baseUrl = get_env_info
        if '{time}' in monitoringinfo['request']['url']:
            url = baseUrl + monitoringinfo['request']['url'].replace('{component}','kube-apiserver').replace('{time}',str(datetime.now()).split('.')[0])
        else:
            url = baseUrl + monitoringinfo['request']['url'].replace('{component}','kube-apiserver')
        method = monitoringinfo['request']['method']
        req = RequestUtil().send_request(method, url)
        assert req.status_code == monitoringinfo['validate'][0]['equals']['status_code']

    @pytest.mark.parametrize('monitoringinfo', YamlUtil().read_testcase_yaml('v24.06/monitoring/8_get_control_plane_metric_range_vector_kubeapiserver.yaml'))
    def test_get_control_plane_metric_range_vector_kubeapiserver(self, monitoringinfo, get_env_info):
        # 查询控制平面组件的指标数据-kube-apiserver-范围向量
        baseUrl = get_env_info
        starttime = datetime.now() - timedelta(minutes=10)
        endtime = datetime.now()
        url = baseUrl + monitoringinfo['request']['url'].replace('{component}','kube-apiserver').replace('{starttime}', str(starttime).split('.')[0]).replace('{endtime}', str(endtime).split('.')[0]).replace('{steptime}', '5m')
        method = monitoringinfo['request']['method']
        req = RequestUtil().send_request(method, url)
        assert req.status_code == monitoringinfo['validate'][0]['equals']['status_code']

    @pytest.mark.parametrize('monitoringinfo', YamlUtil().read_testcase_yaml('v24.06/monitoring/9_get_control_plane_metric_etcd.yaml'))
    def test_get_control_plane_metric_etcd(self, monitoringinfo, get_env_info):
        # 查询控制平面组件的指标数据-etcd
        baseUrl = get_env_info
        if '{time}' in monitoringinfo['request']['url']:
            url = baseUrl + monitoringinfo['request']['url'].replace('{component}','etcd').replace('{instance}',datas.etcd_instance).replace('{time}',str(datetime.now()).split('.')[0])
        else:
            url = baseUrl + monitoringinfo['request']['url'].replace('{component}','etcd').replace('{instance}',datas.etcd_instance)
        method = monitoringinfo['request']['method']
        req = RequestUtil().send_request(method, url)
        assert req.status_code == monitoringinfo['validate'][0]['equals']['status_code']

    @pytest.mark.parametrize('monitoringinfo', YamlUtil().read_testcase_yaml('v24.06/monitoring/9_get_control_plane_metric_range_vector_etcd.yaml'))
    def test_get_control_plane_metric_range_vector_etcd(self, monitoringinfo, get_env_info):
        # 查询控制平面组件的指标数据-etcd-范围向量
        baseUrl = get_env_info
        starttime = datetime.now() - timedelta(minutes=10)
        endtime = datetime.now()
        url = baseUrl + monitoringinfo['request']['url'].replace('{component}','etcd').replace('{instance}',datas.etcd_instance).replace('{starttime}', str(starttime).split('.')[0]).replace('{endtime}', str(endtime).split('.')[0]).replace('{steptime}', '5m')
        method = monitoringinfo['request']['method']
        req = RequestUtil().send_request(method, url)
        assert req.status_code == monitoringinfo['validate'][0]['equals']['status_code']

    @pytest.mark.parametrize('monitoringinfo', YamlUtil().read_testcase_yaml('v24.06/monitoring/10_get_control_plane_metric_kubescheduler.yaml'))
    def test_get_control_plane_metric_kubescheduler(self, monitoringinfo, get_env_info):
        # 查询控制平面组件的指标数据-kubescheduler
        baseUrl = get_env_info
        if '{time}' in monitoringinfo['request']['url']:
            url = baseUrl + monitoringinfo['request']['url'].replace('{component}','kube-scheduler').replace('{instance}',datas.kube_scheduler_instance).replace('{time}',str(datetime.now()).split('.')[0])
        else:
            url = baseUrl + monitoringinfo['request']['url'].replace('{component}','kube-scheduler').replace('{instance}',datas.kube_scheduler_instance)
        method = monitoringinfo['request']['method']
        req = RequestUtil().send_request(method, url)
        # print(req.content)
        assert req.status_code == monitoringinfo['validate'][0]['equals']['status_code']

    @pytest.mark.parametrize('monitoringinfo', YamlUtil().read_testcase_yaml('v24.06/monitoring/10_get_control_plane_metric_range_vector_kubescheduler.yaml'))
    def test_get_control_plane_metric_range_vector_kubescheduler(self, monitoringinfo, get_env_info):
        # 查询控制平面组件的指标数据-kube-scheduler-范围向量
        baseUrl = get_env_info
        starttime = datetime.now() - timedelta(minutes=10)
        endtime = datetime.now()
        url = baseUrl + monitoringinfo['request']['url'].replace('{component}','kube-scheduler').replace('{instance}',datas.kube_scheduler_instance).replace('{starttime}', str(starttime).split('.')[0]).replace('{endtime}', str(endtime).split('.')[0]).replace('{steptime}', '5m')
        method = monitoringinfo['request']['method']
        req = RequestUtil().send_request(method, url)
        assert req.status_code == monitoringinfo['validate'][0]['equals']['status_code']

    @pytest.mark.parametrize('monitoringinfo', YamlUtil().read_testcase_yaml('v24.06/monitoring/11_get_control_plane_metric_kubecontrollermanager.yaml'))
    def test_get_control_plane_metric_kubecontrollermanager(self, monitoringinfo, get_env_info):
        # 查询控制平面组件的指标数据-kube-controller-manager
        baseUrl = get_env_info
        if '{time}' in monitoringinfo['request']['url']:
            url = baseUrl + monitoringinfo['request']['url'].replace('{component}', 'kube-controller-manager').replace(
                '{instance}', datas.kube_scheduler_instance).replace('{time}', str(datetime.now()).split('.')[0])
        else:
            url = baseUrl + monitoringinfo['request']['url'].replace('{component}', 'kube-controller-manager').replace(
                '{instance}', datas.kube_scheduler_instance)
        method = monitoringinfo['request']['method']
        req = RequestUtil().send_request(method, url)
        assert req.status_code == monitoringinfo['validate'][0]['equals']['status_code']

    @pytest.mark.parametrize('monitoringinfo', YamlUtil().read_testcase_yaml('v24.06/monitoring/11_get_control_plane_metric_range_vector_kubecontrollermanager.yaml'))
    def test_get_control_plane_metric_range_vector_kubecontrollermanager(self, monitoringinfo, get_env_info):
        # 查询控制平面组件的指标数据-kube-controller-manager-范围向量
        baseUrl = get_env_info
        starttime = datetime.now() - timedelta(minutes=10)
        endtime = datetime.now()
        url = baseUrl + monitoringinfo['request']['url'].replace('{component}', 'kube-controller-manager').replace('{instance}',datas.kube_scheduler_instance).replace('{starttime}', str(starttime).split('.')[0]).replace('{endtime}', str(endtime).split('.')[0]).replace('{steptime}', '5m')
        method = monitoringinfo['request']['method']
        req = RequestUtil().send_request(method, url)
        assert req.status_code == monitoringinfo['validate'][0]['equals']['status_code']

    @pytest.mark.parametrize('monitoringinfo', YamlUtil().read_testcase_yaml('v24.06/monitoring/12_get_node_component_metric_kubelet.yaml'))
    def test_get_node_component_metric_kubelet(self, monitoringinfo, get_env_info):
        # 查询节点组件的指标数据-kubelet
        baseUrl = get_env_info
        if '{time}' in monitoringinfo['request']['url']:
            url = baseUrl + monitoringinfo['request']['url'].replace('{component}','kubelet').replace('{instance}',datas.kubelet_instance).replace('{time}',str(datetime.now()).split('.')[0])
        else:
            url = baseUrl + monitoringinfo['request']['url'].replace('{component}','kubelet').replace('{instance}',datas.kubelet_instance)
        method = monitoringinfo['request']['method']
        req = RequestUtil().send_request(method, url)
        assert req.status_code == monitoringinfo['validate'][0]['equals']['status_code']

    @pytest.mark.parametrize('monitoringinfo', YamlUtil().read_testcase_yaml('v24.06/monitoring/12_get_node_component_metric_range_vector_kubelet.yaml'))
    def test_get_node_component_metric_range_vector_kubelet(self, monitoringinfo, get_env_info):
        # 查询节点组件的指标数据-kubelet-范围向量
        baseUrl = get_env_info
        starttime = datetime.now() - timedelta(minutes=10)
        endtime = datetime.now()
        url = baseUrl + monitoringinfo['request']['url'].replace('{component}','kubelet').replace('{instance}',datas.kubelet_instance).replace('{starttime}', str(starttime).split('.')[0]).replace('{endtime}', str(endtime).split('.')[0]).replace('{steptime}', '5m')
        method = monitoringinfo['request']['method']
        req = RequestUtil().send_request(method, url)
        assert req.status_code == monitoringinfo['validate'][0]['equals']['status_code']

    @pytest.mark.parametrize('monitoringinfo', YamlUtil().read_testcase_yaml('v24.06/monitoring/13_get_node_component_metric_kubeproxy.yaml'))
    def test_get_node_component_metric_kubeproxy(self, monitoringinfo, get_env_info):
        # 查询节点组件的指标数据-kube-proxy
        baseUrl = get_env_info
        if '{time}' in monitoringinfo['request']['url']:
            url = baseUrl + monitoringinfo['request']['url'].replace('{component}','kube-proxy').replace('{instance}',datas.kube_proxy_instance).replace('{time}',str(datetime.now()).split('.')[0])
        else:
            url = baseUrl + monitoringinfo['request']['url'].replace('{component}','kube-proxy').replace('{instance}',datas.kube_proxy_instance)
        method = monitoringinfo['request']['method']
        req = RequestUtil().send_request(method, url)
        assert req.status_code == monitoringinfo['validate'][0]['equals']['status_code']

    @pytest.mark.parametrize('monitoringinfo', YamlUtil().read_testcase_yaml('v24.06/monitoring/13_get_node_component_metric_range_vector_kubeproxy.yaml'))
    def test_get_node_component_metric_range_vector_kubeproxy(self, monitoringinfo, get_env_info):
        # 查询节点组件的指标数据-kubelet-范围向量
        baseUrl = get_env_info
        starttime = datetime.now() - timedelta(minutes=10)
        endtime = datetime.now()
        url = baseUrl + monitoringinfo['request']['url'].replace('{component}','kubelet').replace('{instance}',datas.kube_proxy_instance).replace('{starttime}', str(starttime).split('.')[0]).replace('{endtime}', str(endtime).split('.')[0]).replace('{steptime}', '5m')
        method = monitoringinfo['request']['method']
        req = RequestUtil().send_request(method, url)
        assert req.status_code == monitoringinfo['validate'][0]['equals']['status_code']

    @pytest.mark.parametrize('monitoringinfo', YamlUtil().read_testcase_yaml('v24.06/monitoring/14_get_addon_component_metric.yaml'))
    def test_get_addon_component_metric(self, monitoringinfo, get_env_info):
        # 查询addon组件的指标数据
        baseUrl = get_env_info
        if '{time}' in monitoringinfo['request']['url']:
            url = baseUrl + monitoringinfo['request']['url'].replace('{instance}',datas.addon_instance).replace('{time}',str(datetime.now()).split('.')[0])
        else:
            url = baseUrl + monitoringinfo['request']['url'].replace('{instance}',datas.addon_instance)
        method = monitoringinfo['request']['method']
        req = RequestUtil().send_request(method, url)
        assert req.status_code == monitoringinfo['validate'][0]['equals']['status_code']

    @pytest.mark.parametrize('monitoringinfo', YamlUtil().read_testcase_yaml('v24.06/monitoring/14_get_addon_component_metric_range_vector.yaml'))
    def test_get_addon_component_metric_range_vector(self, monitoringinfo, get_env_info):
        # 查询addon组件的指标数据-范围向量
        baseUrl = get_env_info
        starttime = datetime.now() - timedelta(minutes=10)
        endtime = datetime.now()
        url = baseUrl + monitoringinfo['request']['url'].replace('{instance}',datas.addon_instance).replace('{starttime}', str(starttime).split('.')[0]).replace('{endtime}', str(endtime).split('.')[0]).replace('{steptime}', '5m')
        method = monitoringinfo['request']['method']
        req = RequestUtil().send_request(method, url)
        assert req.status_code == monitoringinfo['validate'][0]['equals']['status_code']

    @pytest.mark.parametrize('monitoringinfo', YamlUtil().read_testcase_yaml('v24.06/monitoring/15_get_user_promql.yaml'))
    def test_get_user_promql(self, monitoringinfo, get_env_info):
        # 用户自定义表达式查询
        baseUrl = get_env_info
        if '{time}' in monitoringinfo['request']['url']:
            url = baseUrl + monitoringinfo['request']['url'].replace('{expr}',datas.expr).replace('{time}',str(datetime.now()).split('.')[0])
        else:
            url = baseUrl + monitoringinfo['request']['url'].replace('{expr}',datas.expr)
        method = monitoringinfo['request']['method']
        req = RequestUtil().send_request(method, url)
        # print(req.content)
        assert req.status_code == monitoringinfo['validate'][0]['equals']['status_code']

    @pytest.mark.parametrize('monitoringinfo', YamlUtil().read_testcase_yaml('v24.06/monitoring/15_get_user_promql_range_vector.yaml'))
    def test_get_user_promql_range_vector(self, monitoringinfo, get_env_info):
        # 用户自定义表达式查询-范围向量
        baseUrl = get_env_info
        starttime = datetime.now() - timedelta(minutes=10)
        endtime = datetime.now()
        url = baseUrl + monitoringinfo['request']['url'].replace('{expr}',datas.expr).replace('{starttime}', str(starttime).split('.')[0]).replace('{endtime}', str(endtime).split('.')[0]).replace('{steptime}', '5m')
        method = monitoringinfo['request']['method']
        req = RequestUtil().send_request(method, url)
        assert req.status_code == monitoringinfo['validate'][0]['equals']['status_code']

    @pytest.mark.parametrize('monitoringinfo', YamlUtil().read_testcase_yaml('v24.06/monitoring/16_get_targets_list.yaml'))
    def test_get_targets_list(self, monitoringinfo, get_env_info):
        # 获取监控目标列表
        baseUrl = get_env_info
        starttime = datetime.now() - timedelta(minutes=10)
        endtime = datetime.now()
        url = baseUrl + monitoringinfo['request']['url']
        method = monitoringinfo['request']['method']
        req = RequestUtil().send_request(method, url)
        # print(req.content)
        assert req.status_code == monitoringinfo['validate'][0]['equals']['status_code']

    @pytest.mark.parametrize('monitoringinfo', YamlUtil().read_testcase_yaml('v24.06/monitoring/17_get_alert_rule_list.yaml'))
    def test_get_alert_rule_list(self, monitoringinfo, get_env_info):
        # 获取告警规则列表
        baseUrl = get_env_info
        url = baseUrl + monitoringinfo['request']['url']
        method = monitoringinfo['request']['method']
        req = RequestUtil().send_request(method, url)
        # print(req.content)
        assert req.status_code == monitoringinfo['validate'][0]['equals']['status_code']